from sqlalchemy import create_engine, Column, Integer, String, text
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

from blog.sqlalchemy_mysql_article import Article

# pip install sqlalchemy mysql-connector-python
# 创建数据库引擎
# 请根据实际情况修改数据库连接信息
engine = create_engine('mysql+mysqlconnector://root:Wit2cloud!24@43.138.226.128:3306/ssc-platform')

Session = sessionmaker(bind=engine)
# 创建会话实例
session = Session()

# 定义 SQL 查询语句并使用 text 函数
sql_query = text("SELECT * FROM blog_article")

# 执行 SQL 查询语句
result = session.execute(sql_query,{id:1})

# 遍历查询结果
for row in result:
    print(row)

# 关闭会话
session.close()
